﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nyamr;

namespace WordCount
{
    public class WordReducer : BaseReducer
    {
        public override void Reduce(string key, IEnumerable<byte[]> values, IEmitter emitter)
        {
            var total = 0;
            foreach (var value in values)
            {
                total += int.Parse(Encoding.UTF8.GetString(value));
            }
            emitter.Emit(key, Encoding.UTF8.GetBytes(total.ToString()));
        }

        public override void Dispose() { }
    }
}
